import Vue from 'vue'
import App from './App.vue'
import router from "@/router/index"; // 引入路由
import store from "@/store/index"; // 引入vuex
import "@/mock/mockServe"; // 引入mock数据
import "swiper/css/swiper.css"; // 引swiper样式包

// 三级联动组件——全局组件
import cascade from "@/components/cascade/cascade.vue";
Vue.component(cascade.name,cascade)

// 轮播图组件注册
import Carousel from "@/components/Carousel";
Vue.component(Carousel.name,Carousel)

// 轮播图组件注册
import Pagination from "@/components/Pagination";
Vue.component(Pagination.name,Pagination)

// 导入全部的api接口
import * as API from "@/api/cart";
import * as api from "@/api/pay";

// 按需导入element-ui的组件
import { Button, MessageBox } from "element-ui";
Vue.use(Button)
Vue.prototype.$msgbox = MessageBox;
Vue.prototype.$alert = MessageBox.alert;

// 引入图片懒加载插件
import VueLazyload from "vue-lazyload";
import loading from "@/assets/loading.gif";
import error from "@/assets/1.gif";
Vue.use(VueLazyload, {
  preLoad: 1.3,
  error: error, // 出错默认图片
  loading: loading, // 懒加载默认图片
  attempt: 1
})

// 引入表单校验插件
import "@/plugins/validate";

Vue.config.productionTip = false

new Vue({
  store, // 组件实例的身上会多一个$store属性
  // 全局事件总线
  beforeCreate(){
    Vue.prototype.$bus=this
    Vue.prototype.$API=API
    Vue.prototype.$api=api
  },
  router,
  render: h => h(App),
}).$mount('#app')
